<template>
  <div class="hello">
    <h1>{{ msg }}</h1>
    <p>

    </p>

  </div>
</template>

<script>
import Mock from "mockjs";
export default {
  name: "HelloWorld",
  data() {
    return {
      msg: "测试页面",
      testData: [],
    };
  },
  mounted() {
    this.init();
  },
  methods: {
    init() {
      let { testData } = Mock.mock({
        "testData|1000": [Mock.Random.cname()],
      });
      this.testData = testData;
      console.time();
      console.log("mapFn test", this.testData);
      this.mapFn();

      console.timeEnd();
      console.time();
      console.log("forFn test", this.testData);
      this.forFn();

      console.timeEnd();
    },
    mapFn() {
      if (this.testData && this.testData.length > 0) {
        this.testData.map((item) => {
          console.log(" test item", item);
        });
      }
    },
    forFn() {
      if (this.testData && this.testData.length > 0) {
        for (let i = 0; i < this.testData.length; i++) {
          let item = this.testData[i];
          console.log(" test item", item);
        }
      }
    },
  },
};
</script>
<style scoped lang="scss">
</style>
